﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Recommend.Api.Data;

namespace Recommend.Api.Controllers
{
    [Route("api/Recommends")]
    public class RecommendController : BaseController
    {
        private readonly RecommendDbContext _recommendDbContext;
        private readonly ILogger<BaseController> _logger;

        public RecommendController(RecommendDbContext recommendDbContext ,ILogger<BaseController> logger) : base(logger)
        {
            _recommendDbContext = recommendDbContext;
            _logger = logger;
        }

        [HttpGet]
        [Route("")]
        public async Task<IActionResult> GetAsync()
        {
            return Ok(await _recommendDbContext.ProjectRecommends.AsNoTracking()
                .Where(b => b.UserId == UserIdentity.UserId).ToListAsync());
        }

    }
}